/**
 *
 * Copyright by Samuel Castro & Joaquim Fonseca, 2011
 * All Rights Reserved
 *
 * NOTES:
 * Please do not redistribute this plugin without my permission
 * Plugin made for private use only
 *
 */
package com.SySammy.SdBountyHunter.Listeners;

import com.SySammy.SdBountyHunter.Handlers.BountyHandler;
import com.SySammy.SdBountyHunter.Prop.BountyHunterProperties;
import com.SySammy.SdBountyHunter.sdLaw;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.block.BlockListener;

public class BListener extends BlockListener {

    sdLaw plugin;

    public BListener(sdLaw plugin) {
        this.plugin = plugin;
    }

    @Override
    public void onBlockBreak(BlockBreakEvent event) {
        final Player p = event.getPlayer();
        BountyHandler BH = new BountyHandler(plugin);
        if (BH.GetCaught(p.getName())) {
            p.sendMessage(ChatColor.RED + "You are under arrest, do your time and don't ever come back.");
            p.sendMessage(ChatColor.DARK_AQUA + "The arrest time on the server is: " + ChatColor.GOLD + BountyHunterProperties.arrestTime + " minutes");
            event.setCancelled(true);
        }
    }
}
